<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../assert_selection.js"></script>
<script>
// To verify "mac" behavior other than macOS, please add following lines:
//   internals.settings.setEditingBehavior('mac');
//   internals.settings.setSelectTrailingWhitespaceEnabled(false);
const isMac = navigator.platform.indexOf('Mac') === 0;

selection_test(
  '<div contenteditable dir="ltr">|abc def<div><br></div><div><br></div><div><br></div>uvw xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">|abc def<div><br></div><div><br></div><div><br></div>uvw xyz</div>',
  '2-0 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">a|bc def<div><br></div><div><br></div><div><br></div>uvw xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">|abc def<div><br></div><div><br></div><div><br></div>uvw xyz</div>',
  '2-1 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">ab|c def<div><br></div><div><br></div><div><br></div>uvw xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">|abc def<div><br></div><div><br></div><div><br></div>uvw xyz</div>',
  '2-2 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc| def<div><br></div><div><br></div><div><br></div>uvw xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">|abc def<div><br></div><div><br></div><div><br></div>uvw xyz</div>',
  '2-3 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc |def<div><br></div><div><br></div><div><br></div>uvw xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">|abc def<div><br></div><div><br></div><div><br></div>uvw xyz</div>',
  '2-4 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc d|ef<div><br></div><div><br></div><div><br></div>uvw xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc |def<div><br></div><div><br></div><div><br></div>uvw xyz</div>',
  '2-5 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc de|f<div><br></div><div><br></div><div><br></div>uvw xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc |def<div><br></div><div><br></div><div><br></div>uvw xyz</div>',
  '2-6 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc def|<div><br></div><div><br></div><div><br></div>uvw xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc |def<div><br></div><div><br></div><div><br></div>uvw xyz</div>',
  '2-7 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc def<div>|<br></div><div><br></div><div><br></div>uvw xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc def|<div><br></div><div><br></div><div><br></div>uvw xyz</div>',
  '2-8 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc def<div><br>|</div><div><br></div><div><br></div>uvw xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc def|<div><br></div><div><br></div><div><br></div>uvw xyz</div>',
  '2-9 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc def<div><br></div>|<div><br></div><div><br></div>uvw xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc def<div>|<br></div><div><br></div><div><br></div>uvw xyz</div>',
  '2-10 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc def<div><br></div><div>|<br></div><div><br></div>uvw xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc def<div>|<br></div><div><br></div><div><br></div>uvw xyz</div>',
  '2-11 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br>|</div><div><br></div>uvw xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc def<div>|<br></div><div><br></div><div><br></div>uvw xyz</div>',
  '2-12 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div>|<div><br></div>uvw xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc def<div><br></div><div>|<br></div><div><br></div>uvw xyz</div>',
  '2-13 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div><div>|<br></div>uvw xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc def<div><br></div><div>|<br></div><div><br></div>uvw xyz</div>',
  '2-14 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div><div><br>|</div>uvw xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc def<div><br></div><div>|<br></div><div><br></div>uvw xyz</div>',
  '2-15 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div><div><br></div>|uvw xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div><div>|<br></div>uvw xyz</div>',
  '2-16 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div><div><br></div>u|vw xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div><div><br></div>|uvw xyz</div>',
  '2-17 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div><div><br></div>uv|w xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div><div><br></div>|uvw xyz</div>',
  '2-18 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div><div><br></div>uvw| xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div><div><br></div>|uvw xyz</div>',
  '2-19 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div><div><br></div>uvw |xyz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div><div><br></div>|uvw xyz</div>',
  '2-20 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div><div><br></div>uvw x|yz</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div><div><br></div>uvw |xyz</div>',
  '2-21 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div><div><br></div>uvw xy|z</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div><div><br></div>uvw |xyz</div>',
  '2-22 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div><div><br></div>uvw xyz|</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc def<div><br></div><div><br></div><div><br></div>uvw |xyz</div>',
  '2-23 ltr left word');
</script>
